package com.yequan.work;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author yequan
 * @date 2021/04/27 15:46
 **/
public class HHH {

    public static void main(String[] args) {
        selectByRulesOfUse1(null);
    }

//    private static List<CouponInfo> selectByRulesOfUse(List<CouponInfo> driverCoupons) {
//        /* 99*/
//        return driverCoupons.stream().sorted(Comparator.comparing(o -> Double.valueOf(o.getPrice())).reversed()
//                .thenComparing(CouponInfo::getExpire_time)
//                .thenComparing((o1, o2) -> Integer.parseInt(o2.getCouponSetInfo().getCoupon_type()) - Integer.parseInt(o1.getCouponSetInfo().getCoupon_type())))
//                .collect(Collectors.toList());
//    }
//
//    private static List<CouponInfo> selectByRulesOfUse(List<CouponInfo> driverCoupons) {
//        /* 99*/
//        return driverCoupons.stream().sorted(Comparator.comparing(o -> Double.valueOf(o.getPrice())).reversed()
//                .thenComparing(CouponInfo::getExpire_time)
//                .thenComparing((o1, o2) -> Integer.parseInt(o2.getCouponSetInfo().getCoupon_type()) - Integer.parseInt(o1.getCouponSetInfo().getCoupon_type())))
//                .collect(Collectors.toList());
//    }
//
//    private static List<CouponInfo> selectByRulesOfUse(List<CouponInfo> driverCoupons) {
//        /* 99*/
//        return driverCoupons.stream().sorted(Comparator.comparing(o -> Double.valueOf(o.getPrice())).reversed().thenComparing(CouponInfo::getExpire_time).thenComparing((o1, o2) -> Integer.parseInt(o2.getCouponSetInfo().getCoupon_type()) - Integer.parseInt(o1.getCouponSetInfo().getCoupon_type()))).collect(Collectors.toList());
//    }
//
//    private static List<CouponInfo> selectByRulesOfUse(List<CouponInfo> driverCoupons) {
//        /* 99*/
//        return driverCoupons.stream().sorted(Comparator.comparing(o -> Double.valueOf(o.getPrice())).reversed().thenComparing(CouponInfo::getExpire_time).thenComparing((o1, o2) -> Integer.parseInt(o2.getCouponSetInfo().getCoupon_type()) - Integer.parseInt(o1.getCouponSetInfo().getCoupon_type()))).collect(Collectors.toList());
//
//
//    }

    private static List<CouponInfo> selectByRulesOfUse1(List<CouponInfo> driverCoupons) {
        if (driverCoupons == null){
            return null;
        }
        return driverCoupons.stream().sorted(Comparator.comparing((CouponInfo o) -> Double.valueOf(o.getPrice())).reversed()
                .thenComparing(CouponInfo::getExpire_time)
                .thenComparing((o1, o2) -> Integer.parseInt(o2.getCouponSetInfo().getCoupon_type()) - Integer.parseInt(o1.getCouponSetInfo().getCoupon_type())))
                .collect(Collectors.toList());
    }

}
